package com.mvp.shq.washer.ui.rule;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Html;
import android.widget.ImageView;
import android.widget.TextView;

import com.mvp.shq.washer.R;
import com.mvp.shq.washer.base.BaseActivity;
import com.mvp.shq.washer.ui.aboutUs.AboutUsActivity;
import com.mvp.shq.washer.utils.T;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RuleActivity extends BaseActivity<Presenter, Model> implements RuleConstract.View {


    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.tv_rule)
    TextView tvRule;

    @Override
    public int getLayoutId() {
        return R.layout.activity_rule;
    }

    @Override
    public void initView() {
        String key = getIntent().getExtras().getString("key");
        showLoadingDialog(true);
        presenter.getRule(key);
    }


    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void getRuleS(String content) {
        CharSequence charSequence = Html.fromHtml(content, new Html.ImageGetter() {
            @Override
            public Drawable getDrawable(String source) {
                Drawable drawable=RuleActivity.this.getResources().getDrawable(R.mipmap.fail_img);
//                //下面这句话不可缺少
                drawable.setBounds(0,0,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());
                return drawable;
            }
        },null);
        tvRule.setText(charSequence);
    }

    @Override
    public void getRuleF(String msg) {
        T.show(msg);
    }
}
